/*     */ package com.zimbra.cs.util.tnef.mapi;
/*     */ 
/*     */ import java.io.IOException;
/*     */ import net.freeutils.tnef.RawInputStream;
/*     */ import net.freeutils.tnef.TNEFUtils;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class GlobalObjectId
/*     */ {
/*  62 */   private static final byte[] thirdPartyWaterMark = { 118, 67, 97, 108, 45, 85, 105, 100, 1, 0, 0, 0 };
/*     */   
/*     */ 
/*     */   private String icalUid;
/*     */   
/*     */ 
/*     */   private int origInstanceYear;
/*     */   
/*     */ 
/*     */   private int origInstanceMonth;
/*     */   
/*     */   private int origInstanceDay;
/*     */   
/*     */ 
/*     */   public GlobalObjectId(RawInputStream ris)
/*     */     throws IOException
/*     */   {
/*  79 */     byte[] allData = ris.toByteArray();
/*  80 */     RawInputStream risCopy = new RawInputStream(allData);
/*  81 */     risCopy.readBytes(16);
/*  82 */     setOrigInstanceYear(risCopy);
/*  83 */     setOrigInstanceMonth(risCopy);
/*  84 */     setOrigInstanceDay(risCopy);
/*  85 */     risCopy.readBytes(8);
/*  86 */     risCopy.readBytes(8);
/*  87 */     long dataSize = risCopy.readU32();
/*  88 */     boolean isWrappedIcalUid = false;
/*     */     
/*  90 */     if (dataSize > thirdPartyWaterMark.length) {
/*  91 */       isWrappedIcalUid = true;
/*  92 */       byte[] testWaterMark = risCopy.readBytes(thirdPartyWaterMark.length);
/*  93 */       for (int cnt = 0; cnt < thirdPartyWaterMark.length; cnt++) {
/*  94 */         if (thirdPartyWaterMark[cnt] != testWaterMark[cnt]) {
/*  95 */           isWrappedIcalUid = false;
/*  96 */           break;
/*     */         }
/*     */       }
/*     */     }
/* 100 */     if (isWrappedIcalUid) {
/* 101 */       Long uidLen = Long.valueOf(dataSize - thirdPartyWaterMark.length);
/* 102 */       byte[] icalUidBytes = risCopy.readBytes(uidLen.intValue());
/* 103 */       this.icalUid = new String(icalUidBytes, "UTF8");
/* 104 */       this.icalUid = TNEFUtils.removeTerminatingNulls(this.icalUid);
/*     */     }
/*     */     else {
/* 107 */       for (int cnt = 16; cnt <= 19; cnt++) {
/* 108 */         allData[cnt] = 0;
/*     */       }
/* 110 */       StringBuffer s = new StringBuffer();
/* 111 */       for (cnt = 0; cnt < allData.length; cnt++) {
/* 112 */         String b = Integer.toHexString(allData[cnt] & 0xFF).toUpperCase();
/* 113 */         if (b.length() == 1)
/* 114 */           s.append('0');
/* 115 */         s.append(b);
/*     */       }
/* 117 */       this.icalUid = s.toString();
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getIcalUid()
/*     */   {
/* 126 */     return this.icalUid;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public int getOrigInstanceYear()
/*     */   {
/* 133 */     return this.origInstanceYear;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public int getOrigInstanceMonth()
/*     */   {
/* 140 */     return this.origInstanceMonth;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public int getOrigInstanceDay()
/*     */   {
/* 147 */     return this.origInstanceDay;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private void setOrigInstanceYear(RawInputStream ris)
/*     */     throws IOException
/*     */   {
/* 156 */     int firstByte = ris.readU8();
/* 157 */     int secondByte = ris.readU8();
/* 158 */     this.origInstanceYear = ((firstByte << 8) + secondByte);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   private void setOrigInstanceMonth(RawInputStream ris)
/*     */     throws IOException
/*     */   {
/* 166 */     this.origInstanceMonth = ris.readU8();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   private void setOrigInstanceDay(RawInputStream ris)
/*     */     throws IOException
/*     */   {
/* 174 */     this.origInstanceDay = ris.readU8();
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/util/tnef/mapi/GlobalObjectId.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */